import React from 'react';
import { Row, Col } from 'antd';
import _ from 'lodash';
import { useTranslation } from 'react-i18next';

interface Props {
  data: any;
}
export default function Index(props: Props) {
  const { t } = useTranslation('datasourceManage');
  const { data } = props;

  return (
    <div data-oid='w3o:88v'>
      <div className='page-title' data-oid='q4._wrg'>
        HTTP
      </div>
      <div className='flash-cat-block' data-oid='e5o.g4f'>
        <Row gutter={16} data-oid='-7.8c9:'>
          <Col span={24} data-oid='qrgsala'>
            URL：
          </Col>
          <Col span={24} className='second-color' data-oid='qcpo6b:'>
            {data?.http?.url}
          </Col>
        </Row>
      </div>
      <div className='page-title' data-oid='x324cee'>
        {t('form.auth')}
      </div>
      <div className='flash-cat-block' data-oid='mxl8xz3'>
        <Row gutter={16} data-oid='oqo-.ok'>
          <Col span={8} data-oid='_ytav4v'>
            {t('form.username')}：
          </Col>
          <Col span={8} data-oid='coq70nt'>
            {t('form.password')}：
          </Col>
          <Col span={8} data-oid='5uq7dq9'>
            {t('form.skip_ssl_verify')}：
          </Col>
          <Col span={8} className='second-color' data-oid='fk7tcw8'>
            {data?.auth?.basic_auth ? data?.auth?.basic_auth_user : '-'}
          </Col>
          <Col span={8} className='second-color' data-oid='-2bdxd5'>
            {data?.auth?.basic_auth ? '******' : '-'}
          </Col>
          <Col span={8} className='second-color' data-oid='cp_qabj'>
            {data.http?.tls?.skip_tls_verify ? t('form.yes') : t('form.no')}
          </Col>
        </Row>
      </div>
      {data?.http?.headers && (
        <>
          <div className='page-title' data-oid='13qqdog'>
            {t('form.headers')}
          </div>
          <div className='flash-cat-block' data-oid='ed88:-a'>
            <Row gutter={16} data-oid='zilo5ax'>
              {_.map(data?.http?.headers, (val, key) => {
                return (
                  <Col key={key} span={24} data-oid='_nfz5t5'>
                    {key + ' : ' + val}
                  </Col>
                );
              })}
            </Row>
          </div>
        </>
      )}
      <div className='page-title' data-oid='s9vhl_j'>
        {t('form.other')}
      </div>
      <div className='flash-cat-block' data-oid='x5hxuzk'>
        <Row gutter={16} data-oid='weoy9cu'>
          <Col span={24} data-oid='i5zjczo'>
            {t('form.cluster')}：
          </Col>
          <Col span={24} className='second-color' data-oid='1.kklm0'>
            {data?.cluster_name || '-'}
          </Col>
        </Row>
      </div>
    </div>
  );
}
